package com.zmm.book.keep.controller;

import com.zmm.book.keep.model.Bill;
import com.zmm.common.base.model.Result;
import com.zmm.util.auth.registry.annotation.AuthAnonymous;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * description:
 * name TestController
 *
 * @author 900045
 * date By 2021-11-03 17:34:01
 */
@AuthAnonymous
@RestController
@RequestMapping("/test")
public class TestController {

	@Autowired
	RestTemplate loadRestTemplate;


	@GetMapping("/get")
	public Result get(){
		return Result.ok();
	}

	@GetMapping("/hello")
	public String hello(String name){
		Result result = loadRestTemplate.getForObject("http://localhost:9000/customer/address/query/list", Result.class);
		return "访问provider 返回 : " + result;
	}

	@GetMapping("/hello2")
	public String hello2(String name){
		Result result1 = loadRestTemplate.getForObject("http://localhost:9000/customer/address/query/list", Result.class);
		Result result2 = loadRestTemplate.getForObject("http://localhost:9000/customer/address/query/list", Result.class);
		return "访问provider 返回 : " + result2;
	}

	@PostMapping("/setUser")
	public String setUser(@RequestBody Bill bill){
		Result result = loadRestTemplate.postForObject("http://localhost:9000/customer/address/query/list", bill, Result.class);
		return "访问provider 返回 : " + result;
	}
}
